package com.dou.yygh.common.utils;

import com.dou.yygh.common.helper.JWTHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA 2021.1 x64
 *
 * @Author: 窦义超
 * @Date: 2021/11/2021/11/7/16:26
 * @Description:
 */
public class AuthContextHolder {
    public static Long getUserId(HttpServletRequest request) {
        //从header获取token
        String token = request.getHeader("token");
        //jwt从token获取userid
        Long userId = JWTHelper.getUserId(token);
        return userId;

    }

    //获取当前用户名称
    public static String getUserName(HttpServletRequest request) {
        //从header获取token
        String token = request.getHeader("token");
        //jwt从token获取userid
        String userName = JWTHelper.getUserName(token);
        return userName;
    }

}
